package net.xo68.destiny.contract.enums;

/**
 * 节点注册类型
 * @author wuxie
 * @version 2020-11-4
 */
public enum NodeTypeEnum {

    /**
     * 未知
     */
    UNKNOWN(0),
    /**
     * 任务管理调度节点
     */
    MANAGER(1),
    /**
     * 任务工作节点
     */
    WORKER(1);

    private final int code;

    NodeTypeEnum(int code) {
        this.code = code;
    }

    public int getCode() {
        return code;
    }

    public static NodeTypeEnum of(int code){
        for (NodeTypeEnum recordType: NodeTypeEnum.values()){
            if(code == recordType.getCode()){
                return recordType;
            }
        }
        return NodeTypeEnum.UNKNOWN;
    }
}
